//
//  RSAUtil.h
//  Encryption
//
//  Created by 雷传营 on 16/1/10.
//  Copyright © 2016年 leichuanying. All rights reserved.
//

#import <Foundation/Foundation.h>
//#import <UIKit/UIKit.h>

@interface RSAUtil : NSObject

//公钥
#define RSA_Public_key         @"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnRh8MAqfpBZffouPsU3hToRZl3soo2ntYU4psQtc72QOvnprQ6Ua6UBY0WqemCJF/KxQ8p+vY7/r5eZ97Fw7Sq40PQTNKvyxFQuMGRAO8xTahSn2/79KViq7mVVLm2UAH8QaFmq7rJJbkCif3I1yiFMqzOF41ak231GF8eD62gr9+DFLiR1UKjv+/qXG4UjFQM6pa0cD1kAOsoYz0dSQlHFMbOaVf+VEWxSqFjKPiep6bYoViTlMRkdLqbUbHr/xk67C8lGqWO7wnB32T0+fYwnFWF952OJ9kov9oSnvOFXa+NwlAe7m2hZtFnW/NoBX1WxkQ6zTTTxJb8sRNft7qQIDAQAB"

//私钥
#define RSA_Privite_key        @"MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQC7SNle+VEIE5flHbBbtr4Dp1yJAPYXYNCo45pXI8YfV9DEF1Wf8d+CIFhc8Mih1pJJMNyXWuOV6lSIBmPJOnOJ5mAOjq3HLmdwHW2zzl+tzQMXTzOf7PO2PiD3MhTtDynPFgn7bAjVdw3O3R5pYEJTsNkqOOnmJFO4o1wsnlUt7TDw9+8b4DCoYM36P7nbdXv2jzWl2EEnmHNaF2TM7rZfZVrsSNxD2SkM0Oxp+pfOFcTJ/suISzJCQNbNYJm5k3sNCEquIl6l+sWoKqWRQe2N3otLCWgSrFh2t9Me4rHEsRQkX7TnW+sRp/ABUzZKDrmepZs8jXUTYMFuvfBI1VgpAgMBAAECggEAL7KfAcw3cfojfkuwZbtF64JNU+s1wcB7g/frj/PheowP9FEJEqI0TVzVhF4iiu0t9owGMloIil7Sxo3yDgbf9CgDINH/ujG8UFZ+YQPXZFl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Key:(NSString *)pubKey;
// return raw datax
+ (NSData *)encryptData:(NSData *)data publicKey:(NSString *)pubKey;
// return base64 encoded string
// enc with private key NOT working YET!
//+ (NSString *)encryptString:(NSString *)str privateKey:(NSString *)privKey;
// return raw data
//+ (NSData *)encryptData:(NSData *)data privateKey:(NSString *)privKey;

// decrypt base64 encoded string, convert result to string(not base64 encoded)
+ (NSString *)decryptString:(NSString *)str publicKey:(NSString *)pubKey;
+ (NSData *)decryptData:(NSData *)data publicKey:(NSString *)pubKey;
+ (NSString *)decryptString:(NSString *)str privateKey:(NSString *)privKey;
+ (NSData *)decryptData:(NSData *)data privateKey:(NSString *)privKey;
@end

